<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    
    <title></title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="<%=basePath%>ext-3.2.1/resources/css/ext-all.css"/>
	<script type="text/javascript" src="<%=basePath%>ext-3.2.1/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="<%=basePath%>ext-3.2.1/ext-all.js"></script>
	<script type="text/javascript" src="<%=basePath%>ext-3.2.1/ux/PageComboResizer.js"></script>
	<script type="text/javascript" src="<%=basePath%>ext-3.2.1/ext-lang-zh_CN.js"></script>
		
	<script type="text/javascript" src="<%=basePath%>scripts/jquery-1.4.2.js"></script>
	<script type="text/javascript" src="<%=basePath%>scripts/apputil.js"></script>
	<script type="text/javascript" src="<%=basePath%>pages/organization/hospital.js"></script>
	<link rel="stylesheet" href="../scripts/kindeditor-4.1/themes/default/default.css" />
	<link rel="stylesheet" href="../scripts/kindeditor-4.1/plugins/code/prettify.css" />
	<script charset="utf-8" src="../scripts/kindeditor-4.1/kindeditor-min.js"></script>
	<script charset="utf-8" src="../scripts/kindeditor-4.1/lang/zh_CN.js"></script>
	<script charset="utf-8" src="../scripts/kindeditor-4.1/plugins/code/prettify.js"></script>
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
	  <style type="text/css">
	  body{
	    font-size: 12px;
	  }
	  	.td{
			height: 25px;
		}
		.tdB {
			border-bottom:1px solid #0190FB;
		}
		
		.tdL {
			border-left:1px solid #0190FB;
		}
		
		.tdR {
			border-right:1px solid #0190FB;
		}
		
		.tdT {
			border-top:1px solid #0190FB;
		}
	</style>
	<script type="text/javascript">
		function checkForm(){
		var name = $("#name");
	/*	if("" != name.val()){
			if(!checkName(name.val())){
				alert("医院名称只能为汉字");
				name.focus();
				return false;
			}
		}*/
		
	    var city = $("#city");
	    if (city.val()=="") {
	        alert("请选择地区！")
	        city.focus();
	        return false;
	    }
	    
	    if (name.val()=="") {
	        alert("医院名称不能为空！")
	        name.focus();
	        return false;
	    }
	      var img=$("#img");
	        var imgflag=$("#imgflag");
	      if (img.val()==""&&imgflag.val()==0) {
	        alert("请医院图片！")
	        return false;
	    }
	       if(!validTextareaLength('简介内容过长（最多100个字符）！')){
				return ;
			}
		if(document.getElementById("video")){	
		 var url = $("#video").val();
	    var extend ;
		if(url!=""){
		  	extend = url.substring(url.lastIndexOf(".")+1);
			if(!(extend=="flv")){
			   alert("请上传后缀名为flv的视频文件!");
			   return false;
			}
        }	
        }
	     document.forms[0].submit();
	    
	}
   function  modifyPic(id){
       $("#modifyPic").html('<input type="file" name="imgFile" id="img"/>&nbsp;&nbsp;&nbsp;<input type="button" value="取消" onclick="movePic()"/>');
       $('#'+id).hide();
   }
    function  modifyvideo(id){
       $("#modifyvideo").html('<input type="file" name="videoFile" id="video"/>&nbsp;&nbsp;&nbsp;<input type="button" value="取消" onclick="movevideo()"/>');
       $('#'+id).hide();
   }
   
   function  movePic(){
      var picbtn=document.getElementById("picbtn");
      $("#modifyPic").html('');
      picbtn.style.display='inline';
   }
   function  movevideo(){
      var videobtn=document.getElementById("videobtn");
      $("#modifyvideo").html('');
      videobtn.style.display='inline';
   }
	</script>
	<body>
	<form action="<%=basePath%>hospital/save.action" method="post" id="myform" name="myform" enctype="multipart/form-data"> 
	<div align="center">
	<table width="80%" border="0" cellspacing="1" cellpadding="5" class="tabCls" style="margin-top: 10px;">
		<tr>
			<td colspan="4" align="center" bgcolor="#ffffff">
				<span style="font-size: 25px; font: ; font-weight: bold;">医院信息维护</span>&nbsp;<font color='red'>(*为必填项)</font>
			</td>
		</tr>
	</table>
		<table width="90%" border="0" style="margin-top: 10px;" cellpadding="0" cellspacing="0">
			<tr>
				<td class="tdT tdR tdL" width="20%" align="right"><font color='red'>*</font>地区：</td>
				<td class="tdT" align="left">&nbsp;省：</td>
				<td class="tdT tdR" align="left"><div id="districtCombox"></div></td>
				<td class="tdT" align="left">&nbsp;市：</td>
				<td class="tdT tdR" align="left"><div id="districtCombox_child"></div></td>
			</tr>
			
			<tr>
				<td align="right" class="tdT tdR tdL" ><font color='red'>*</font>医院名称：</td>
				<td colspan="4" class="tdT tdR" align="left" width="100%"><input id="name" type="text" size="50" maxlength="30" value="<s:property value="hospital.name"/>" name="hospital.name"></td>
			</tr>
			
			<tr>
				<td align="right" class="tdT tdR tdL " >医院等级：</td>
				<td colspan="4" class="tdT tdR " width="100%" align="left">
			       	<SELECT id="dlevel" name="hospital.dlevel" class="loginInput"></SELECT>
				</td>
			</tr>
			
			<tr>
				<td align="right" class="tdT tdR tdL " >医院性质：</td>
				<td colspan="4" class="tdT tdR " width="100%" align="left">
			       	<SELECT id="type" name="hospital.type" class="loginInput"></SELECT>
				</td>
			</tr>
			<tr>
				<td align="right" class="tdT tdR tdL " ><font color='red'>*</font>图片：</td>
				<c:if test="${hospital.imgsrc != null}">
				<td align="left"  colspan="4" class="tdT tdR ">
				<input type="hidden" value="1" id="imgflag">
					<img src="<%=basePath%>${hospital.imgsrc}" id="img" width="149" height="92"/>&nbsp;<a href="<%=basePath%>${hospital.imgsrc}" target="_blank"/>浏览原图</a>&nbsp;&nbsp;&nbsp;<s:if test="flag==1"><span id="picbtn"><input type="button"  onclick="modifyPic('picbtn')" value="修改"/></span></s:if>
				     <div id="modifyPic"></div>
				</td>
				</c:if>
				<c:if test="${hospital.imgsrc == null}">
				<td align="left"  colspan="4" class="tdT tdR ">
				<input type="hidden" value="0" id="imgflag">
					<input type="file" name="imgFile" id="img" size="69"/> 
				</td>
				</c:if>
			</tr>
			
			<tr>
				<td align="right" class="tdR tdL tdT tdB" >视频：</td>
				<c:if test="${hospital.videosrc != null}">
				<td align="left"  colspan="4" class="tdR tdL tdT  ">
					<a href="../pages/flvplay.jsp?url=<%=basePath%>${hospital.videosrc}" target="_blank"/>浏览视频</a>&nbsp;&nbsp;&nbsp;<s:if test="flag==1"><span id="videobtn"><input type="button"  onclick="modifyvideo('videobtn')" value="修改"/></span></s:if>
				     <div id="modifyvideo"></div>
				</td>
				</c:if>
				<c:if test="${hospital.videosrc == null}">
				<td align="left"  colspan="4" class="tdR tdL  tdT ">
					<input type="file" name="videoFile" id="video" size="69"/> 
				</td>
				</c:if>
			</tr>
			
			
			<tr>
				<td align="right" class="tdR tdL tdB">简介：</td>
				<td class="tdR tdT" colspan="4" align="left">
				<textarea style="width:770px;height:80px;word-wrap:break-word;" onkeyup="if(this.value.length>100){alert('输入内容过长');this.style.border='double red';return false}else{this.style.border='1px #D4D0C8 solid';}" name="hospital.summary" id="content2"  ><s:property value="hospital.summary" /></textarea>
				</td>
			</tr>
			<tr>
				<td align="right" class="tdR tdL tdB">描述：</td>
				<td class="tdR tdB tdT" colspan="4" align="left">
				<textarea style="width:770px;height:300px;word-wrap:break-word;" name="hospital.description" id="content1"><s:property value="hospital.description" /></textarea>
				</td>
			</tr>
		</table>
		
		
		<input type="hidden" id="proviceId" name="hospital.proviceId" value="<s:property value="hospital.proviceId"/>"/>
		<input type="hidden" id="proviceName" name="hospital.proviceName" value="<s:property value="hospital.proviceName"/>"/>
		<input type="hidden" id="districtId" name="hospital.districtId" value="<s:property value="hospital.districtId"/>"/>
		<input type="hidden" id="districtName" name="hospital.districtName" value="<s:property value="hospital.districtName"/>"/>
		<input type="hidden" id="id" name="hospital.id" value="<s:property value="hospital.id"/>"/>
		<input type="hidden" id="deleteFlag" name="hospital.deleteFlag" value="<s:property value="hospital.deleteFlag"/>"/>
		<input type="hidden" name="hospital.Imgsrc" value="<s:property value="hospital.Imgsrc"/>"/>
		<input type="hidden" name="hospital.videosrc" value="<s:property value="hospital.videosrc"/>"/>
		<input type="hidden" id="city" value="<s:property value="hospital.proviceId"/>"/>
		
		<table width="80%" class="tabCls">
		<tr>
			<td align="center">
			<s:if test="flag==1">
				<input type="button" id="save" name="Submit" value="保 存" 
					onClick="checkForm()" class="button_sty saveBtn" />
			</s:if>
				<input type="button" id="reset" name="reset" value="返 回"
						onClick="goBackReset()" class="button_sty backBtn" />
			</td>
		</tr>
	</table>
	</div>
	</form>
	</body>
	<script type="text/javascript">
		var proviceId = $("#proviceId").val();
		var proviceName = $("#proviceName").val();
		var districtId = $("#districtId").val();
		var districtName = $("#districtName").val();
		var editor;
        KindEditor.ready(function(K) {
		               editor = K.create('#content1', {
		               allowFileManager : true,
		               uploadJson : '../scripts/kindeditor-4.1/upload_json.jsp',
				       fileManagerJson : '../scripts/kindeditor-4.1/file_manager_json.jsp',
				          afterBlur:function(){ 
				            this.sync(); 
				        },  
                       items : [
					 	           'preview','source', '|', 'undo', 'redo', '|',  'cut', 'copy', 'paste',
						        'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
						        'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
						        'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
						        'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
						        'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image',
						       'insertfile', 'table', 'hr', 'emoticons', 'map', 'pagebreak',
						        'link', 'unlink'
                  ]
                        
                });
        });
		var dlevelValue = '${hospital.dlevel}';
		$.get('../dataPlugin/buildJsonData.action?tablename=hospital_level',function(mes){
			var mesJson = eval('('+mes+')');
			var disJson = mesJson[0]['result'];
			initSelect('dlevel',disJson,dlevelValue,function(){});
		})
		
		var typeValue = '${hospital.type}';
		$.get('../dataPlugin/buildJsonData.action?tablename=hospital_type',function(mes){
			var mesJson = eval('('+mes+')');
			var disJson = mesJson[0]['result'];
			initSelect('type',disJson,typeValue,function(){});
		})
	</script>
	
	
	
</html>
